﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Text;
using System.Collections.Generic;

namespace exsportance.Silverlight.Validate
{
    /// <summary>
    /// The result of a validation
    /// </summary>
    public class ValidationResult
    {
        public static ValidationResult Empty = new ValidationResult();

        #region properties
        /// <summary>
        /// Result is valid
        /// </summary>
        public bool Result { get; set; }

        /// <summary>
        /// Messages from Validators
        /// </summary>
        public ValidationMessages Messages { get; private set; }

        /// <summary>
        /// Indicates if a value was provided to validators e.g. User has typed a value to the control
        /// </summary>
        public bool ValueProvided { get; set; }

        /// <summary>
        /// The name of the item which was valid
        /// </summary>
        public string ValidItemName { get; set; }
        #endregion

        #region constructor
        /// <summary>
        /// Creates a new ValidationResult
        /// </summary>
        public ValidationResult()
        {
            Messages = new ValidationMessages();
            Result = true;
        }
        #endregion

        /// <summary>
        /// Get all messages as string
        /// </summary>
        /// <returns></returns>
        public string GetMessages()
        {
            return Messages.ToString();
        }

        /// <summary>
        /// Get all messages related to a control
        /// </summary>
        /// <param name="frameworkElement"></param>
        /// <returns></returns>
        public ValidationMessages GetMessages(FrameworkElement control)
        {
            return Messages.GetByControl(control);
        }
    }
}
